<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>无标题文档</title>
	<link href="${pageContext.request.contextPath}/css/sys.css" type="text/css" rel="stylesheet" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/Calendar.js"></script>
	<script src="jquery-1.8.3.min.js"></script>
</head>

<body class="emp_body">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr>
		<td class="topg"></td>
	</tr>
</table>

<table border="0" cellspacing="0" cellpadding="0"  class="wukuang"width="100%">
	<tr>
		<td width="1%"><img src="${pageContext.request.contextPath}/images/tleft.gif"/></td>
		<td width="44%" align="left">[员工管理]</td>

		<td width="52%"align="right">
			<!-- 提交表单 -->
			<a href="javascript:void(0)" onclick="document.forms[0].submit()">
				<img src="${pageContext.request.contextPath}/images/button/save.gif" />
			</a>
			<!-- 执行js，进行返回 -->
			<a href="javascript:void(0)" onclick="window.history.go(-1)"><img src="${pageContext.request.contextPath}/images/button/tuihui.gif" /></a>

		</td>
		<td width="3%" align="right"><img src="${pageContext.request.contextPath}/images/tright.gif"/></td>
	</tr>
</table>

<form action="/crm2/staff/staffAction_edit.action" method="post">

	<input type="hidden" name="staffId" value="2c9091c14c78e58b014c78e7ecd90007"/>

	<table width="88%" border="0" class="emp_table" style="width:80%;">
		<tr>
			<td>登录名：</td>
			<td><s:textfield name="loginName"/></td>
			<td>密码：</td>
			<td> <s:password name="loginPwd" showPassword="true"/> </td>
		</tr>

		<tr>
			<td>姓名：</td>
			<td> <s:textfield name="staffName" /> </td>
			<td>性别：</td>
			<td> <s:radio list="{'男','女'}" name="gender" /> </td>

		</tr>
		<tr>
			<td width="10%">所属部门：</td>
			<td width="20%">
				<select name="post.department.depId" onchange="changeDepartment()" id="sel1">
					<option value="">----请--选--择----</option>
					<s:iterator value="allDepartment">
						<option value="<s:property value='depId'/>"><s:property value="depName"/></option>
					</s:iterator>
				</select>

			</td>
			<td width="8%">职务：</td>
			<td width="62%">
				<select name="post" id="postSelectId">
					<option value=""><s:property value="postName"/></option>
				</select>

			</td>
		</tr>

		<tr>
			<td width="10%">入职时间：</td>
			<td width="20%">
				<s:date name="onDutyDate" format="yyyy-MM-dd" var="myDate"/>
				<s:textfield name="onDutyDate" readonly="true" value="%{#myDate}" onfocus="c.showMoreDay=true;c.show(this);" />
			</td>
			<td width="8%"></td>
			<td width="62%"></td>

		</tr>

	</table>
</form>

<script>
    function changeDepartment() {
        // 获取部门Id
        var depId = $("#sel1").val();
        //allert(depId)
        // json传递参数
        var params = {
            "depId": depId,
        }
        $.ajax({
            // 发送ajax请求，后台得到请求数据，处理请求之后，返回的json数据再用js的jquery方式解析
            // 请求的action路径
            url:"${pageContext.request.contextPath}/findPost",
            // post请求方式
            type:"post",
            // 请求参数
            data:params,
            // 后台处理返回的数据，通过ajax方式
            success:function(data){
                var sel2=$("#postSelectId");
                // 清空
                sel2.empty();
                if(data!=null)
                {
                    // 使用eval() 函数将JSON的字符串解析成JSON数据格式
                    var items=eval(data);
                    sel2.append("<option value = '-1'>----请--选--择----</option>");
                    // 遍历数据
                    for(var i =0;i<items.length;i++)
                    {

                        var item=items[i]

                        sel2.append("<option value ='item.postId'>"+item.postName+"</option>");
                    };
                }
                else
                {
                    sel2.empty();
                }
            },
            error: function(){
                return;
            }
        });
    }
</script>

</body>
</html>
